<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:p="http://primefaces.org/ui"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
                xmlns:constants="http://www.tuanzi.com/constants/tags">
    <div class="ui-g">
        <div class="ui-g-12">
            <h3>
                <b>贷款说明信息</b>
            </h3>
        </div>
        <div class="ui-g-2">
            <p:outputLabel value="模板名称"/>
        </div>
        <div class="ui-g-4">
            <p:inputText value="#{firstPartyTagInfoBean.$.activityName}"
                         disabled="#{firstPartyTagInfoBean.isView()}"/>
        </div>

        <div class="ui-g-2">
            <p:outputLabel value="模板备注"/>
        </div>
        <div class="ui-g-4">
            <p:inputText value="#{firstPartyTagInfoBean.$.activityMemo}"
                         disabled="#{firstPartyTagInfoBean.isView()}"/>
        </div>

        <div class="ui-g-2">
            <p:outputLabel value="活动模板"/>
        </div>
        <div class="ui-g-10">
            <p:selectOneMenu value="#{firstPartyTagInfoBean.activityModelRequest.activityModelId}" filter="true"
                             filterMatchMode="contains" disabled="#{firstPartyTagInfoBean.isView()}"
                             style="width:150px">
                <p:ajax event="change" listener="#{firstPartyTagInfoBean.onChangeActivityModel()}"
                        process="@this"
                        update="dynaPanel"/>
                <f:selectItems value="#{firstPartyTagInfoBean.activityModels}" var="activityModel"
                               itemLabel="#{activityModel.modelName}" itemValue="#{activityModel.id}"/>
            </p:selectOneMenu>
        </div>

        <p:outputPanel id="dynaPanel">
            <c:forEach items="#{firstPartyTagInfoBean.$.loanProductModelViews}" var="model" varStatus="status">
                <c:if test="${model.type == 0}">
                    <div class="ui-g-2">
                        <p:outputLabel value="#{model.label}"/>
                    </div>
                    <div class="ui-g-10">
                        <p:inputText value="#{model.text}" disabled="#{firstPartyTagInfoBean.isView()}"/>
                    </div>
                </c:if>

                <c:if test="${model.type == 1}">
                    <div class="ui-g-2">
                        <p:outputLabel value="#{model.label}"/>
                    </div>
                    <div class="ui-g-10">
                        <p:outputPanel>
                            <div class="ui-g-3">
                                <p:fileUpload fileUploadListener="#{firstPartyTagInfoBean.onUploadImage}"
                                              mode="advanced"
                                              fileLimit="1"
                                              auto="true" style="width: 100px"
                                              fileLimitMessage="只能上传一个文件"
                                              invalidFileMessage="不支持上传文件类型"
                                              invalidSizeMessage="文件过大"
                                              sizeLimit="#{constants:get('UPLOAD_FILE_SIZE')}"
                                              allowTypes="/(\.|\/)(#{constants:get('UPLOAD_FILE_SUFFIX')})$/"
                                              label="上传" update="dynaPanel" process="dynaPanel"
                                              disabled="#{firstPartyTagInfoBean.isView()}">
                                    <f:attribute name="uploadIndex" value="#{status.count}"/>
                                </p:fileUpload>
                            </div>
                            <div class="ui-g-7">
                                <p:graphicImage url="#{model.imgUrl}" width="100%"/>
                            </div>
                        </p:outputPanel>
                    </div>
                </c:if>

                <c:if test="${model.type == 2}">
                    <div class="ui-g-2">
                        <p:outputLabel value="#{model.label}"/>
                    </div>
                    <div class="ui-g-10">
                        <p:outputPanel>
                            <div class="ui-g-3">
                                <p:fileUpload fileUploadListener="#{firstPartyTagInfoBean.onUploadImageText}"
                                              mode="advanced"
                                              fileLimit="1"
                                              auto="true" style="width: 100px"
                                              fileLimitMessage="只能上传一个文件"
                                              invalidFileMessage="不支持上传文件类型"
                                              invalidSizeMessage="文件过大"
                                              sizeLimit="#{constants:get('UPLOAD_FILE_SIZE')}"
                                              allowTypes="/(\.|\/)(#{constants:get('UPLOAD_FILE_SUFFIX')})$/"
                                              label="上传" update="dynaPanel" process="dynaPanel"
                                              disabled="#{firstPartyTagInfoBean.isView()}">
                                    <f:attribute name="uploadIndex" value="#{status.count}"/>
                                </p:fileUpload>
                            </div>
                            <div class="ui-g-7">
                                <p:graphicImage url="#{model.imgTextUrl}" width="100%"/>
                            </div>

                            <div class="ui-g-10">
                                <p:inputTextarea value="#{model.imgText}" disabled="#{firstPartyTagInfoBean.isView()}"/>
                            </div>
                        </p:outputPanel>
                    </div>
                </c:if>

                <c:if test="${model.type == 3}">
                    <div class="ui-g-2">
                        <p:outputLabel value="#{model.label}"/>
                    </div>
                    <div class="ui-g-10">
                        <p:calendar
                                styleClass="autoWidthCalendar"
                                value="#{model.date}"
                                locale="#{constants:get('LOCALE')}"
                                timeZone="#{constants:get('TIME_ZONE')}"
                                pattern="#{constants:get('DATE_FORMAT')}"
                                disabled="#{firstPartyTagInfoBean.isView()}"/>
                    </div>
                </c:if>

                <c:if test="${model.type == 4}">
                    <div class="ui-g-2">
                        <p:outputLabel value="#{model.label}"/>
                    </div>
                    <div class="ui-g-12">
                        <p:selectOneMenu value="#{model.isTrue}" style="width:125px"
                                         disabled="#{firstPartyTagInfoBean.isView()}">
                            <f:selectItem itemLabel="是" itemValue="1"/>
                            <f:selectItem itemLabel="否" itemValue="0"/>
                        </p:selectOneMenu>
                    </div>
                </c:if>

                <c:if test="${model.type == 5}">
                    <div class="ui-g-12">
                        <p:outputLabel value="#{model.label}"/>

                        <p:commandButton style="float: right" icon="fa fa-plus" update="dynaPanel" process="dynaPanel"
                                         actionListener="#{firstPartyTagInfoBean.onAddRow(status.count)}"
                                         disabled="#{firstPartyTagInfoBean.isView()}"/>
                    </div>
                    <div class="ui-g-12">
                        <p:dataTable var="item" value="#{model.oneListObjects}" emptyMessage="暂无数据"
                                     draggableRows="true">
                            <p:column>
                                <p:inputText value="#{item.text}" disabled="#{firstPartyTagInfoBean.isView()}"/>
                            </p:column>
                        </p:dataTable>
                    </div>
                </c:if>
            </c:forEach>
        </p:outputPanel>
    </div>
</ui:composition>